home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 114 / pathfind.lst < prev    next >
File List  |  1987-11-28  |  3KB  |  72 lines

  1. '  Procedure Set_path   will call up the the file selector box with the systems
  2. '  default pathname, the default filename, and default extention search pattern.
  3. '  The procedure will find the default path by itself.
  4. '  YOU must call this procedure with :
  5. '   1st - a string which is the default filename. ie "EXAMPLE.TXT" or ""
  6. '   2nd - a string which is the default extension search pattern, ie "BAS" "DOC"
  7. '   3rd - a string variable name which has an astrisk in front of it, indicating
  8. '         a return variable. After the routine finishes it puts the selected
  9. '         filename in that string, such as "HELLO.TXT" or "TEXTWORK.BAS".
  10. '
  11. '  Procedure Deafult_path    simply returns the systems default path. You must
  12. '  call it with a string variable name with an asterisk in front of it to
  13. '  indicate that this is a return string variable. When this routine is done
  14. '  it will place the deafult path name into this string variable.
  15. '
  16. '  Note that selecting CANCEL will keep the defaults the same.
  17. '
  18. Do
  19.   @Set_path(F$,"BAS",*F$)
  20.   @Default_path(*A$)       !Sample loop to show how to use the two procedures.
  21.   Print A$,F$
  22. Loop
  23. '
  24. '
  25. '
  26. '
  27. '
  28. ' ---------======<<<(( determines system default directory ))>>>======---------
  29. '  input  variables  : none.
  30. '  returned variables: Present_path (pointer to string variable containing
  31. '                      currently recognized directory.)
  32. '
  33. Procedure Default_path(Present_path)
  34.   Local Default_drive$
  35.   Default_drive$=Chr$(Gemdos(25)+65)
  36.   *Present_path=Default_drive$+":"+Dir$(Gemdos(25)+1)+"\"
  37. Return
  38. '
  39. '
  40. '
  41. '  ---------======<<<(( user sets system default-directory ))>>>======---------
  42. '  input  variables  : Default_file$ (Default file name)
  43. '                    : Extension$ (extension to filename for search pattern)
  44. '  returned variables: File_selected (returns filename selected)
  45. '
  46. Procedure Set_path(Default_file$,Extension$,File_selected)
  47.   Local Starting_path$,Selected_path$,Size_name,File_name$,Default_drive$
  48.   Default_drive$=Chr$(Gemdos(25)+65)
  49.   Starting_path$=Default_drive$+":"+Dir$(Gemdos(25)+1)+"\"
  50.   If Extension$=""
  51.     Extention$="*"
  52.   Endif
  53.   If Default_file$=""
  54.     Default_file$=""
  55.   Endif
  56.   Fileselect Starting_path$+"*."+Extension$,Default_file$,Selected_path$
  57.   If Selected_path$=""
  58.     Goto No_change
  59.   Endif
  60.   Chdrive Asc(Left$(Selected_path$,1))-64
  61.   File_path$=Right$(Selected_path$,Len(Selected_path$)-2)
  62.   Size_name=Len(Selected_path$)
  63.   Do
  64.     Exit If Mid$(Selected_path$,Size_name,1)="\"
  65.     File_name$=Mid$(Selected_path$,Size_name,1)+File_name$
  66.     Dec Size_name
  67.   Loop
  68.   Chdir Left$(Selected_path$,Len(Selected_path$)-Len(File_name$))
  69.   *File_selected=File_name$
  70.   No_change:
  71. Return